package com.aistar.service.impl;

import com.aistar.mapper.CustomerMapper;
import com.aistar.mapper.DiscountMapper;
import com.aistar.pojo.Discount;
import com.aistar.pojo.DiscountExample;
import com.aistar.service.DiscountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscountServiceImpl implements DiscountService {
    @Autowired
    private DiscountMapper discountMapper;
    @Autowired
    private CustomerMapper customerMapper;

    /**
     * 根据优惠券id 查询优惠券
     * @param disId
     * @return
     */
    @Override
    public List<Discount> getByDisId(Integer disId) {
        Discount discount = null;
        DiscountExample discountExample = new DiscountExample();
        DiscountExample.Criteria criteria = discountExample.createCriteria();
        criteria.andDiscountIdEqualTo(disId);
        criteria.andDiscountStatusEqualTo(1);

        List<Discount> discountList = discountMapper.selectByExample(discountExample);

        for (Discount d:discountList){
            disId = d.getDiscountId();
            discount = discountMapper.selectByPrimaryKey(disId);
            System.out.println(discount);
        }
        return discountList;
    }

//    /*根据用户id查询优惠券*/
//    @Override
//    public List<Discount> getByCusId(Integer cusId) {
//        Integer discountId = 0;
//        List<Discount> discountList = new ArrayList<>();
//        DiscountVO discountVO = null;
//        //根据用户id 查询用户优惠券中的优惠券id
//        Customer customer = customerMapper.selectByPrimaryKey(cusId);
//
//        return null;
//    }


    @Override
    public int save(Discount discount) {
        return 0;
    }

    @Override
    public int modifyStatus(Discount discount) {
        return 0;
    }

    @Override
    public int modify(Discount discount) {
        return 0;
    }

    @Override
    public Discount getById(Integer id) {
        Discount discount = discountMapper.selectByPrimaryKey(id);
        return discount;
    }

    @Override
    public List<Discount> getAll() {
        return null;
    }
}
